#include <stdio.h>
#include <unistd.h>
#include "ohos_init.h" 
#include "ohos_types.h" 
#include "cmsis_os2.h"
static void HelloWorld(void)
{
    while(1)
    {
        printf("[SPARK-HM-PI] Hello world!\n");
        usleep(1000000);
    }
}
static void HelloOpenHarmony(void)
{
    while(1)
    {
        printf("[SPARK-HM-PI] Hello OpenHarmony!\n");
        usleep(2000000);
    }
}
static void HelloEntry(void)
{
    osThreadAttr_t attr;
    attr.name = "HelloWorld"; //线程名称
    attr.attr_bits = 0U;    //线程属性位
    attr.cb_mem = NULL;     //用户指定的控制块指针
    attr.cb_size = 0U;      //用户指定的控制块大小
    attr.stack_mem = NULL;   //用户指定的线程栈指针。
    attr.stack_size = 1024;  //线程栈大小,需要根据实际情况调整
    attr.priority = 20;     //线程优先级,数值越低优先级越高
    if (osThreadNew((osThreadFunc_t)HelloWorld, NULL, &attr) == NULL) //创建线程
    {
        printf("Falied to create HelloWorldTask!\n");
    }
    attr.name = "HelloOpenHarmony"; 
    attr.priority = 19;     //线程优先级,数值越低优先级越高
    if (osThreadNew((osThreadFunc_t)HelloOpenHarmony, NULL, &attr) == NULL) //创建线程
    {
        printf("Falied to create HelloOpenHarmonyTask!\n");
    }
}
SYS_RUN(HelloEntry);